package LeetCode.month02.day59;

import java.util.HashMap;
import java.util.Map;

public class No3005 {
    public int maxFrequencyElements(int[] nums) {
        Map<Integer,Integer> count = new HashMap<>();
        int max = 0;
        int n = nums.length;
        for (int i = 0; i < n; i++) {
            int num = count.getOrDefault(nums[i],0)+1;
            max = Math.max(num,max);            count.put(nums[i],num);
        }
        int res = 0;
        for (Integer value : count.values()) {
            if(value==max) res+=max;
        }
        return res;
    }
}
